#include <iostream>
class Base
{
public:
	~Base() // note: 不是虚函数
	{
		std::cout << "Calling ~Base()\n";
	}
};

class Derived: public Base
{
private:
	int* m_array;

public:
	Derived(int length)
		: m_array{ new int[length] }
	{
	}

	~Derived() // note: 不是 virtual (编译器可能会发出告警)
	{
		std::cout << "Calling ~Derived()\n";
		delete[] m_array;
	}
};

int main()
{
	Derived* derived { new Derived(5) };
	Base* base { derived };

	delete base;//调用基类的析构函数，同时因为它不是虚函数，则子类的析构函数不会被调用，子类成员无法析构

	return 0;
}

//note 在处理涉及继承的类时，其析构函数必须显式定义为虚函数